package project.dao;

import project.pojo.Book;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

/**
 * @author d11yu
 */
public interface BookDAO {
    /**
     * 添加book
     *
     * @param book
     * @return
     */
    public int addBook(Book book);

    /**
     * 根据id删除book
     *
     * @param id
     * @return
     */
    public int deleteBookById(Integer id);

    /**
     * 根据username删除book
     *
     * @param name
     * @return
     */
    public int deleteBookByName(String name);

    /**
     * 根据name更新book
     *
     * @param book
     * @return
     */
    public int updateBookByName(Book book);

    /**
     * 根据id更新book
     *
     * @param book
     * @return
     */
    public int updateBookById(Book book);

    /**
     * 批量更新book
     *
     * @param books
     * @return
     */
    public int[] updateBooksById(List<Book> books) throws NoSuchFieldException, IllegalAccessException;

    /**
     * 批量更新book sales和stock
     *
     * @param books
     * @return
     */
    public int[] updateBooksSalesStockById(List<Book> books) throws NoSuchFieldException, IllegalAccessException;

    /**
     * 查看全部book
     *
     * @return
     * @throws SQLException
     */
    public List<Book> queryAllBooks() throws SQLException;

    /**
     * 根据name查找book
     *
     * @param name 书名
     * @return
     * @throws SQLException
     */
    public Book queryBookByName(String name) throws SQLException;

    /**
     * 根据id查找book
     *
     * @param id
     * @return
     * @throws SQLException
     */
    public Book queryBookById(Integer id) throws SQLException;

    /**
     * 获取总记录条数
     *
     * @return
     * @throws SQLException
     */
    public Integer getEntryCountTotal() throws SQLException;

    /**
     * 获取指定页面的book对象列表
     *
     * @param eStart 起始序号
     * @param ecp    每页条目数
     * @return
     * @throws SQLException
     */
    public List<Book> queryBooksPerPage(int eStart, int ecp) throws SQLException;

    public int getEntryCountTotalByPrice(double minPrice, double maxPrice) throws SQLException;

    List<Book> queryBooksPerPageByPrice(double minPrice, double maxPrice, int eStart, int ecp) throws SQLException;
}
